$(function(){
	$(document).on('click','.view_history',function(){
		var id = $(this).attr('data-id');
		var iid = $(this).attr('data-value');
		var uid = $(this).attr('data-uid');
		var params = {
				url: '/biz/exam/view/'+id,
				type: 'GET',
				dataType: 'json',
				data: {i:iid,uid:uid},
			};
		var html = "";
		var hcontent = "";
		var wrongCount = 0;
		$.ajax(params).done(function(resp){
			if(resp.status == 'success') {
				$('#myModal').modal('hide');
				$('#resumeModal').modal('hide');
				data = resp.data;
				$.each(data.exam.questions ,function(k,v){
					var type='单选题';
					if(v.question_type == 0){
						type = '单选题';
					}else if(v.question_type == 1) {
						type = '多选题';
					}else if(v.question_type == 2) {
						type = '判断题';
					}else if(v.question_type == 3) {
						type = '论述题';
					}
					var lcclass = 'icon-remove';
					if(data.user_answers[v.id] == v.answer) {
						lcclass = 'icon-ok';
					}else{
						wrongCount += 1;
					}
					hcontent += '<li><div class="res_l1">'+
								'<p class="res_l1_1 fl">'+(k+1)+'、［'+type+'］'+v.title+'</p>'+
								'<p class="fr"><span class="'+lcclass+'"></span>&ensp;|&ensp;得分：'+data.score_lists[v.id]+
								'<span class="res_f1_3">满分：'+v.pivot.score+'</span><span class="res_f1_4"></span></p>'+
							'</div>'+
							'<div class="res_l2">';
					$.each(v.options,function (key,val){
						hcontent += '<p><label for="r1_1">'+val+'</label></p>';
							   
					});
					
					hcontent+= '</div>'+
							'<div class="res_l3"><span class="res_l3_1"></span>考生答案：'+data.user_answers[v.id]+'</div>'+
							'<div class="res_l4"><span class="res_l3_1"></span>正确答案：'+v.answer+'</div>'+
							'<div class="res_l5">'+
							'<span class="res_l3_1"></span>题目解析：<br>'+
							'<p>'+v.explain+'</p>'+
							'</div>'+
						   '</li>';
				});
				html += '<div class="res_se">'+'<img src="'+data.logo+'">'+
						'<div class="res_x">'+
							'<h3>'+data.user.real_name+' <span>'+data.invitename+'</span></h3>'+
							'<p>联系电话：'+data.resume.phone+'</p>'+
							'<P>邮箱：'+data.resume.email+'</P>'+
							'</div>'+
							'<div class="res_f">'+data.score+'分</div>'+
						'</div>'+
						'<div class="res_ful">'+
							'<div class="res_tit">全面概括</div>'+	
							'<div class="res_f1">'+
								'<span class="res_f1_1"></span>'+
								'考试时间 '+data.created_at+'&ensp;|&ensp;<span class="">本次考试超过：'+data.paiming.surm+'%的人</span>&ensp;|&ensp;<span class="">本次排名：第'+data.paiming.index+'名</span>'
								+'</span>&ensp;|&ensp;<span class="">总参与数 '+data.paiming.count+' 人</span>'
							+'</div>'+
							'<table class="table table1">'+
								'<thead>'+
								   '<tr>'+	
								   	'<th>'+data.name+'</th><th>技能</th><th>题型</th><th>题目数</th><th>错题数</th><th>得分</th>'+
								   '</tr>'+
							   '</thead>'+
							   '<tbody>'+
								   '<tr>'+
								   '<td><span class="res_t1"></span>题目<span class="colr">'+data.exam.question_count+'</span>道</td>'+
								   '<td><span class="res_t2"></span>'+data.need_name+'</td><td>题型</td><td>'+data.exam.question_count+'</td><td>'+wrongCount+'</td>'+
								   '<td>'+data.score+'</td>'+
								   '</tr><tr>'+
								   '<td><span class="res_t1"></span>总分<span class="colr">'+data.exam.score_count+'</span>分</td>'+
								   '</tr><tr>'+
								   '<td><span class="res_t1"></span>得分<span class="colr">'+data.score+'</span>分</td>  '+
								   '</tr>'+
							   '</tbody>'+
						    '</table>'+
					    '</div>'+
					    '<div class="res_dt">'+
					    	'<div class="res_tit">答题情况</div>'+
					    	'<div class="res_d1">'+data.name+'（共'+data.exam.question_count+'道题）</div>'+
				    		'<div class="res_dl">'+
				    			'<ul>'
				    				+hcontent
								+ '</ul>'+
						   '</div>'+
						'</div>';
				    					
				$(".tan-modal-content").html(html);	
				$(".tan-modal").removeClass("dn");
			} else {
				layer.msg(resp.msg);
			}
		});
	});
});